﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<%@ page contentType="text/html; charset=utf-8"  language="java" import="java.util.*,java.text.*" pageEncoding="UTF-8" isELIgnored="false"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/admin/DatePicker/WdatePicker.js"></script>
<link href="<%=request.getContextPath()%>/js/css/ui-lightness/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />	
<script src="<%=request.getContextPath()%>/js/jquery.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>

<%SimpleDateFormat formatDate=new SimpleDateFormat("yyyy-MM-dd");
  String today=formatDate.format(new Date());
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test</title>
<script type="text/javascript">
function refreshParent()
{
 <c:if test= "${!empty refresh}">
   window.parent.location.reload();
 </c:if>

}

function remove(id){
   document.forms["goodtype"].action="Remove.do?id="+id;
   document.forms["goodtype"].submit();

}

function addtype(){
   document.forms["goodtype"].action="typeadd.do";
   document.forms["goodtype"].submit();

}

function delgoods(id){
    if(confirm("确认删除商品信息?"))
    { 
     document.forms["goodtype"].action="goodsdelete.do?id="+id+"&typeid=${sessionScope.admin_type_id}";
     document.forms["goodtype"].submit();
    }
}

var tel_h=  new Array('135','137','139','150','158','180','186','187','188','189');
var s_array=  new Array('s_1','s_1','s_2','s_3','s_4','s_4','s_1','s_1','s_2','s_4');
var t_hh=  new Array('00','11','12','13','17','18','19','20','21','22','10','15','16','17','22','23','23','20','14','22');

function addcomments(goodsid,goodsname)
{
 $("#comment .goodsname").html(goodsname);
 $("#comment .goodsname").attr('id',goodsid);
 //changeinfo(); 
 $("#comment").dialog('open');

}
function changeinfo()
{
  //手机号头
  $("#comment .tel_h").val(tel_h[parseInt(Math.random()*9)]);
  //手机号尾数
  var tel_l='';
  for( i=0;i<4;i++)
  {
  var radom=Math.floor(Math.random()*10);
  tel_l=tel_l+radom;
  }
  $("#comment .tel_l").val(tel_l);
  //地址
  $("#"+s_array[Math.floor(Math.random()*10)]).attr("SELECTED","SELECTED");
  //时间
  var timer_hh=t_hh[Math.floor(Math.random()*20)];
  var timer_mm=''+Math.floor(Math.random()*6)+Math.floor(Math.random()*10)
  var timer_ss=''+Math.floor(Math.random()*6)+Math.floor(Math.random()*10)
  
   $("#comment .time").val(timer_hh+':'+timer_mm+':'+timer_ss);
   $("#comment .comment").val('');
}
function savecomment()
{
  var goodsid= $("#comment .goodsname").attr('id');
  var user= $("#comment .tel_h").val()+'****'+$("#comment .tel_l").val()+$('#area option:selected').val();
  var time=$("#comment .Wdate").val()+" "+$("#comment .time").val();
  var score=$('#commentscore option:selected').val();
  var comment=$("#comment .comment").val();
  var url='<%=request.getContextPath()%>/goodscomment/save.do?method=saveComment';
      $.get(url,{goodsid:goodsid, user: encodeURI(user),time:time,score:score, comment: encodeURI(comment)}, 
       function(result){	  
       $("#comment .comnum").html('共有'+result+'条评论!');
       $("#goods_"+goodsid).html(result);
       });


}
 $(function(){
  $("#comment").dialog({autoOpen:false,width: 450,height:300,modal:false});
  });
  
function copygoods(goodsid)
{
 document.goodsinfo.action="goodscopy.do?id="+goodsid;
 document.goodsinfo.submit();

}
</script>
</head>
<body onload="refreshParent()"; >
<div id=comment title="评论录入">
<div>
  <div class="goodsname"></div>
  <input class="tel_h" type=text value="186" size=2 maxlength="3" />****<input class="tel_l" type=text value="6360" size=3 maxlength="4"/>
  <select id="area">
      <option id=s_1 value="[臣田村东]">臣田村东</option>
      <option id=s_2 value="[臣田村南]">臣田村南</option>
      <option id=s_3 value="[臣田村西]">臣田村西</option>
      <option id=s_4 value="[臣田村中]">臣田村中</option>
   </select>
  <input  class="Wdate" name="beginDate" style="width:100px" type="text" onclick="WdatePicker()" value="<%=today%>" readonly/>
  <input  class="time" style="width:80px" type="text"/>
</div>
 <div>评分:<select id="commentscore">
         <option value="5">5分(非常满意)</option>
         <option value="4">4分(满意)</option>
         <option value="3">3分(一般)</option>
         <option value="2">2分(不满意)</option>
         <option value="1">1分(非常不满意)</option>
         </select>
</div>
<div><input type=text class="comment" value="" maxlength="20" size="50"/></div>
<div><input type=button value="提交" onclick="savecomment();"/>
<input type=button value="更换用户" onclick=" changeinfo();"/>
<span class="comnum"></span></div>
</div>
<form name="goodtype" action="save.do?id=${sessionScope.admin_type_id}&isnew=${isnew}" method="post">
<table>
<tr>
<input type="hidden" name="id" value="${param.id}" />
<td><input type="submit" value="保存" /></td>
<td><input type="button" value="新增同级目录" onclick="addtype()"/></td>
<c:if test= "${(goodtype.level<3 && fn:length(goodtype.underGoodTypes)==0)||(goodtype.level==3 &&fn:length(goodslist)==0) }">
<td><input type="button" value="删除" onclick="remove('${sessionScope.admin_type_id}');"/></td>
</c:if>
</tr>
</table>
<table>
<tr>
<td>名称:</td><td><input type=text name="typeName" value="${goodtype.typeName}" /></td>
<td>排序:</td><td><input type=text name="sort" value="${goodtype.sort}" /></td>
<td>是否显示:</td>
<td>
<select  name="status"  >
  <option value ="1" <c:if test="${goodtype.status==1}">selected</c:if>>显示</option>
  <option value ="0" <c:if test="${goodtype.status==0}">selected</c:if>>隐藏</option>
</select>


</td>
</tr>
</table>
</form>
<c:if test= "${goodtype.level==3}">
<form name="goodsinfo" action="goodsedit.do?typeid=${sessionScope.admin_type_id}" method="post">
<table >
<tr>
<td colspan="2"><input type="submit" value="新增商品" /></td>
</tr>
<tr>
<td width="5px">ID</td>
<td width="50px">图片</td>
<td width="150px">商品名称</td>
<td width="50px">价格</td>
<td width="50px">成本</td>
<td width="50px">利润</td>
<td width="50px">库存</td>
<td width="50px">特价</td>
<td width="50px">积分</td>
<td width="50px">排序</td>
<td width="50px">显示</td>
<td width="50px">删除</td>
<td width="50px">评论</td>
</tr>
 <c:forEach items="${goodslist}" var="goods">
  <tr >
  <td>${goods.id}</td> 
   <td><img src="<%=request.getContextPath()%>/goodsimages/${goods.id}/index.jpg" width="50px" heigth="50px"/></td>
  <td><a href="goodsedit.do?typeid=${sessionScope.admin_type_id}&goodsid=${goods.id}" >${goods.goodsName}</a></td>
  <td>${goods.price}</td>
  <td>${goods.costPrice}</td>
  <td><fmt:formatNumber value="${(goods.price-goods.costPrice)/goods.price}" pattern="##.#%"/></td>
  <td>${goods.goodsNum}</td>
  <td>${goods.ifDiscount==1?'是':'否'}</td>
  <td>${goods.ifScore==1?'是':'否'}</td> 
  <td>${goods.sort}</td>
  <td>${goods.status==1?'是':'否'}</td> 
  <td><a href="javascript:delgoods('${goods.id}')" >删除</a></td> 
  <td><a  href="javascript:addcomments('${goods.id}','${goods.goodsName}')" >${goods.comments}</a>
   <a  href="javascript:copygoods('${goods.id}')" >复制</a>
  </td> 
  </tr>
 
 </c:forEach>
</table>
</form>
</c:if>
</body>
</html>
